﻿using AutoMapper;
using Tauren.Business.Entity.Const;
using Tauren.Business.Entity.Output;
using Global = Tauren.Business.Entity.Global;
using Input = Tauren.Business.Entity.Input;
using Model = Tauren.Business.Entity.Model;
using OutPut = Tauren.Business.Entity.Output;

namespace Tauren.Business.Mapper
{
    public class UnitinfoProfile : Profile, ICommProfile
    {
        public UnitinfoProfile()
        {
            InitProfile();
        }

        /// <summary>
        /// 初始化Mapper
        /// </summary>
        public void InitProfile()
        {
            CreateMap<Model.Unitinfo, OutPut.Unitinfo_OutPut>().AfterMap((data, viw) =>
            {
                viw.Dic_Creatdate = data.Creatdate is null ? "" : data.Creatdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
                viw.Dic_Modifdate = data.Modifdate is null ? "" : data.Modifdate.Value.ToString(GlobalConst.DATE_FORMAT_SECONDS);
            });
            CreateMap<Input.Unitinfo_Input, Model.Unitinfo>();
            CreateMap<Model.PageUnitModel, PageUnitInfoTable>().AfterMap((data, view) =>
            {
                view.CNName = data.CNName;
                view.ENName = data.ENName;
                view.UnitId = data.UnitId;
                view.UnitCode = data.UnitCode;
                view.Legal = data.Legal;
                view.RowNo = data.RowNo;
                view.Contact = data.Contact;
                view.ParentId = data.ParentId.Value;
                view.Phone = data.Phone;
                view.UnitAddress = data.UnitAddress;
            });
        }
    }
}
